Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@octokit/types
Advanced tools
The @octokit/types npm package provides TypeScript definitions for GitHub's REST API, GraphQL API, and Webhooks. It is designed to be used with other Octokit libraries to offer type safety and auto-completion in code editors, making it easier to work with GitHub's APIs in a TypeScript project.
GitHub REST API Types
Provides types for responses from GitHub's REST API endpoints. This example shows how to type an object representing a GitHub issue as it would be returned from the REST API.
import { RestEndpointMethodTypes } from '@octokit/types';
const issue: RestEndpointMethodTypes['issues']['get']['response']['data'] = {
id: 1,
number: 1347,
title: 'Just a test issue'
};
GitHub GraphQL API Types
Provides types for constructing and receiving responses from GitHub's GraphQL API. This example demonstrates fetching a repository's details using GraphQL and typing the response.
import { graphql } from '@octokit/graphql';
import { Repository } from '@octokit/types';
async function getRepository(owner: string, name: string): Promise<Repository> {
const { repository } = await graphql<{ repository: Repository }>(
`{
repository(owner: "${owner}", name: "${name}") {
id
name
owner {
login
}
}
}`
);
return repository;
}
GitHub Webhooks Types
Includes types for GitHub Webhook events. This example shows how to handle an incoming webhook event with type safety, specifically for an issue event.
import { WebhookEvent } from '@octokit/types';
function handleWebhook(event: WebhookEvent) {
if (event.name === 'issues') {
const action = event.payload.action;
console.log(`Issue action: ${action}`);
}
}
Shared TypeScript definitions for Octokit projects
See all exported types at https://octokit.github.io/types.ts
import { Endpoints } from "@octokit/types";
type listUserReposParameters =
Endpoints["GET /repos/{owner}/{repo}"]["parameters"];
type listUserReposResponse = Endpoints["GET /repos/{owner}/{repo}"]["response"];
async function listRepos(
options: listUserReposParameters
): listUserReposResponse["data"] {
// ...
}
import {
GetResponseTypeFromEndpointMethod,
GetResponseDataTypeFromEndpointMethod,
} from "@octokit/types";
import { Octokit } from "@octokit/rest";
const octokit = new Octokit();
type CreateLabelResponseType = GetResponseTypeFromEndpointMethod<
typeof octokit.issues.createLabel
>;
type CreateLabelResponseDataType = GetResponseDataTypeFromEndpointMethod<
typeof octokit.issues.createLabel
>;
See CONTRIBUTING.md
FAQs
Shared TypeScript definitions for Octokit projects
The npm package @octokit/types receives a total of 14,063,764 weekly downloads. As such, @octokit/types popularity was classified as popular.
We found that @octokit/types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.